package com.youpai.platform.user.service.handler;

import com.youpai.platform.common.entity.resp.BaseResponse;
import com.youpai.platform.common.exceptions.AppException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author welles
 * @version 1.0
 * @description 统一异常处理
 * @date 2021/6/26
 */
@Slf4j
@ResponseBody
@ControllerAdvice
public class GlobalExceptionHandler {


    @ExceptionHandler(value = {AppException.class})
    public BaseResponse<?> error(AppException e) {
        return BaseResponse.fail(e.getCode(),e.getMessage());
    }

}
